
#include "ylogger.h"
#include <string>
#include <iostream>

YLogger& YLogger::instance(void)
{
	static YLogger sInstance;
	return sInstance;
}

void YLogger::init(const char* name)
{

}

void YLogger::debug(const char* file, const int line, const char* fun, const char* fmt, ...)
{
	va_list ap;
	va_start(ap, fmt);
	std::string buf = common(fmt, ap);
	va_end(ap);
    std::cout << buf << std::endl;
}

void YLogger::info(const char* file, const int line, const char* fun, const char* fmt, ...)
{
	va_list ap;
	va_start(ap, fmt);
	std::string buf = common(fmt, ap);
	va_end(ap);

}

void YLogger::warn(const char* file, const int line, const char* fun, const char* fmt, ...)
{
	va_list ap;
	va_start(ap, fmt);
	std::string buf = common(fmt, ap);
	va_end(ap);

}

void YLogger::error(const char* file, const int line, const char* fun, const char* fmt, ...)
{
	va_list ap;
	va_start(ap, fmt);
	std::string buf = common(fmt, ap);
	va_end(ap);

}

void YLogger::fatal(const char* file, const int line, const char* fun, const char* fmt, ...)
{
	va_list ap;
	va_start(ap, fmt);
	std::string buf = common(fmt, ap);
	va_end(ap);

}

std::string YLogger::common(const char* fmt, va_list vList)
{
	va_list ap;
	va_copy(ap, vList);
	std::string buf;
	int size = vsnprintf(nullptr, 0, fmt, ap);
	va_end(ap);
	buf.resize(size + 1);
	va_copy(ap, vList);
	vsnprintf((char*)buf.data(), size + 1 , fmt, ap);
	va_end(ap);
	return buf;
}

YLogger::YLogger()
{
}

YLogger::~YLogger()
{
}








